﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QLPKWeb.Models.FormBean.LichLamViecModel.LichLamViecForm>" %>

<%@ Import Namespace="QLPKWeb.Models.LinQ.LichLamViec" %>
<%@ Import Namespace="QLPKWeb.Models.LinQ.Common" %>
<%@ Import Namespace="QLPKWeb.Models.FormBean.LichLamViecModel" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" language="javascript" src="<%= ResolveUrl("~/Content/Scripts/LichLamViec/LichLamViec.js") %>"></script>
    <script type="text/javascript" language="javascript" src="<%= ResolveUrl("~/Content/Scripts/KiemTra.js") %>"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            selectMenu("LichLamViec-LichLamViec");
            $("#LichLamViec-LichLamViec").parent().attr("class", "opened");
        });
        $(document).ready(function () {
            $("#EventDate").datepicker({ dateFormat: 'dd/mm/yy' });
            $("#EndDate").datepicker({ dateFormat: 'dd/mm/yy' });
            $("#FromDate").datepicker({ dateFormat: 'dd/mm/yy' });
        });

        $(function () {
            $("#ThanhPhan").dialog({
                autoOpen: false,
                modal: true,
                width: 420,
                heigth: 200
            });
            $("#butThanhPhan").click(function () {
                $("#ThanhPhan").dialog("option", "title", 'Chọn thành phần tham gia');
                $("#TypeOfBox").val("0");
                ResertFormThanhPhan();
                $("#ThanhPhan").dialog("open");
                return false;
            });

            $("#butNguoiChuanBi").click(function () {
                $("#ThanhPhan").dialog("option", "title", 'Chọn người chuẩn bị');
                $("#TypeOfBox").val("1");
               ResertFormThanhPhan();
                $("#ThanhPhan").dialog("open");
                return false;
            });
        });
    </script>
    <form id="form" method="post" action="#">
        <input type="hidden" id="InListIdThanhPhan" name="InListIdThanhPhan" value="<%=Model.InListIdThanhPhan %>"/>
        <input type="hidden" id="InListIdNguoiChuanBi" name="InListIdNguoiChuanBi" value="<%=Model.InListIdNguoiChuanBi %>"/>
        <input type="hidden" id="TypeOfBox" name="TypeOfBox" value=""/>
        <input type="hidden" id="ID" name="ID" value="<%=Model.ID %>"/>
        <input type="hidden" id="FromDate" name="FromDate" value="<%=Model.FromDate %>"/>
        <input type="hidden" id="ToDate" name="ToDate" value="<%=Model.ToDate %>"/>
        <div class="box round first fullpage">
            <h4> Đăng ký lịch</h4>
            <table class="form" width="100%">
                <tr>
                    <td colspan="2">
                        <div id="Message" style="font-size: 12px; color: Blue; font-weight: bold">
                            <%= Model.MessageCreateLichLamViec %>
                            <%= Model.MessageEditLichLamViec %>
                        </div>
                    </td> 
                    <td colspan="2">                        
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap" style="width: 10%;">
                        <span>Loại lịch đăng ký</span>
                    </td>
                    <td>
                        <% if (Model.IsView)
                           { %>  
                        <%= Html.DropDownList("IdLoaiLich", Model.ComboboxLoai
                                                        , new { style = "display:inline; width: 80%;", disabled = "disabled" })%>
                        <% } else { %> 
                        <%= Html.DropDownList("IdLoaiLich", Model.ComboboxLoai
                                                        , new { style = "display:inline; width: 80%;" })%>
                        <% } %>
                    </td>
                    <td nowrap="nowrap" align="right">
                        &nbsp;</td>
                    <td>
                        &nbsp;<div id="EventDateMessage" class="red"></div>
                    </td>
                </tr>
                <tr>                    
                    <td nowrap="nowrap">
                        Thời gian đăng ký</td>
                    <td>
                        <input name="EventDate" id="EventDate" <% if(Model.IsView) { %> disabled="disabled" <% } %>
                            value="<%= !string.IsNullOrEmpty(Model.EventDate) ? Model.EventDate : DateTime.Now.ToString("dd/MM/yyyy")%>" />
                            <input name="StartTimeHH" id="StartTimeHH" <% if(Model.IsView) { %> disabled="disabled" <% } %>
                            value="<%= !string.IsNullOrEmpty(Model.StartTimeHH) ? Model.StartTimeHH : DateTime.Now.ToString("HH") %>"
                            style="display:inline; width:20px;"
                            onkeypress = "return keypress(event);" />
                            :
                        <input name="StartTimeMM" id="StartTimeMM" <% if(Model.IsView) { %> disabled="disabled" <% } %>
                            value="<%= !string.IsNullOrEmpty(Model.StartTimeMM) ? Model.StartTimeMM : DateTime.Now.ToString("mm") %>"
                            style="display:inline; width:20px;"
                            onkeypress = "return keypress(event);" />(hh:mm)
                        <%--<input name="StartTime" id="StartTime" <% if(Model.IsView) { %> disabled="disabled" <% } %>
                            value="<%= !string.IsNullOrEmpty(Model.StartTime) ? Model.StartTime : DateTime.Now.ToString("HH:mm")%>" />
                        <div>(hh:mm)</div>--%>
                        <div id="StartTimeMessage" class="red"></div>
                    </td>                   
                    <td nowrap="nowrap" align="right">
                        Thời gian kết thúc</td>
                    <td>
                        <input name="EndDate" id="EndDate" <% if(Model.IsView) { %> 
                            disabled="disabled" <% } %>
                            
                            value="<%= !string.IsNullOrEmpty(Model.EndDate) ? Model.EndDate : DateTime.Now.ToString("dd/MM/yyyy")%>" /><input name="EndTimeHH" id="EndTimeHH" <% if(Model.IsView) { %> disabled="disabled" <% } %>
                            value="<%= !string.IsNullOrEmpty(Model.EndTimeHH) ? Model.EndTimeHH : DateTime.Now.AddHours(2).ToString("HH") %>"
                            style="display:inline; width:20px;"
                            onkeypress = "return keypress(event);" />
                            :
                        <input name="EndTimeMM" id="EndTimeMM" <% if(Model.IsView) { %> disabled="disabled" <% } %>
                            value="<%= !string.IsNullOrEmpty(Model.EndTimeMM) ? Model.EndTimeMM : DateTime.Now.AddHours(2).ToString("mm") %>"
                            style="display:inline; width:20px;"
                            onkeypress = "return keypress(event);" />(hh:mm) 
                        <div id="EndTimeMessage" class="red"></div>
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap">
                        <span>Địa điểm</span>
                    </td>
                    <td colspan="3">
                        <input id="DiaDiem" name="DiaDiem" value="<%= Model.DiaDiem %>" style="width: 85%;" <% if(Model.IsView) { %> disabled="disabled" <% } %> />
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap" valign="middle">
                        <input type="button" value="Thành phần" class="btn btn-grey" id="butThanhPhan" name="butThanhPhan" style="width:120px" <% if(Model.IsView) { %> disabled="disabled" <% } %> />
                    </td>
                    <td colspan="3">
                        <%--<input id="InListTextThanhPhan" name="InListTextThanhPhan" value="<%= Model.InListTextThanhPhan %>" style="width: 85%;" />--%>                        
                        <%--<textarea id="InListTextThanhPhan" name="InListTextThanhPhan" style="width: 85%; text-align: left;" disabled="disabled">
                            <%= !string.IsNullOrEmpty(Model.InListTextThanhPhan) ? Model.InListTextThanhPhan.Trim() : "" %>
                        </textarea>--%>
                        <%= Html.TextArea("InListTextThanhPhan", Model.InListTextThanhPhan, new {style="width: 85%; text-align: left;", disabled="disabled" })%>
                        <div id="ThanhPhanMessage" class="red"></div>
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap">
                        <input type="button" class="btn btn-grey" value="Người chuẩn bị" style="width:120px" id="butNguoiChuanBi" name="butNguoiChuanBi" <% if(Model.IsView) { %> disabled="disabled" <% } %> />
                    </td>
                    <td colspan="3">
                        <input id="InListTextNguoiChuanBi" name="InListTextNguoiChuanBi" value="<%= Model.InListTextNguoiChuanBi %>" style="width: 85%;" disabled="disabled" />
                        <div id="NguoiChuanBiMessage" class="red"></div>
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap">
                        <span>Khách mời</span>
                    </td>
                    <td colspan="3">
                        <input id="KhachMoi" name="KhachMoi" value="<%= Model.KhachMoi %>" style="width: 85%;" <% if(Model.IsView) { %> disabled="disabled" <% } %> />
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap" valign="middle">
                        <span>Nội dung</span>
                    </td>
                    <td colspan="3">
                        <input id="NoiDung" name="NoiDung" value="<%= Model.NoiDung %>" style="width: 85%;" <% if(Model.IsView) { %> disabled="disabled" <% } %> />
                        <%--<textarea id="NoiDung" name="NoiDung" rows="1" style="width: 85%;" cols="0">
                            <%= !string.IsNullOrEmpty(Model.NoiDung) ? Model.NoiDung.Trim() : ""%>
                        </textarea>--%>
                        <div id="NoiDungMessage" class="red"></div>
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap">
                        <span>Đơn vị chủ trì</span>
                    </td>
                    <td colspan="3">
                        <input id="DonViChuTri" name="DonViChuTri" value="<%= Model.DonViChuTri %>" style="width: 85%;" <% if(Model.IsView) { %> disabled="disabled" <% } %> />
                    </td>
                </tr>
                <tr>
                    <td nowrap="nowrap">
                        <span>Ghi chú</span>
                    </td>
                    <td colspan="3">
                        <input id="GhiChu" name="GhiChu" value="<%= Model.GhiChu %>" style="width: 85%; border:1px solid #DDDDDD" <% if(Model.IsView) { %> disabled="disabled" <% } %> />
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                    <% if (!Model.IsView && (Model.Status == null || !Model.Status.Value))
                       { %> 
                        <input type="button" class="btn btn-grey" id="LuuButton" value="Lưu" onclick="javascript:DoCreateOrEdit(<%= Model.ID %>)" />
                        <input type="button" class="btn btn-grey" value="Xóa" onclick="javascript:DoDelete(<%= Model.ID %>)" />
                        <input type="button"  class="btn btn-grey"value="Hủy bỏ" onclick="javascript:window.location.href = basePath + 'LichLamViec/LichLamViec/'" />
                    <% }
                       else
                       { %>
                       <input type="button" value="Quay lại" onclick="javascript:history.back();" />
                    <%} %>
                    </td>
                </tr>
            </table>
        </div>
    </form>

    <%-- Box chọn Thành phần --%>
    <div title="" id="ThanhPhan">
        <form id = "formThanhPhan" method="post" action="<%=ResolveUrl("") %>" target="_parent">
        <div style="overflow:auto; width:auto; height: 350px;">
               <div id="Div1" style="display: block;"
                <% if (Model.ListUserNotInDepartment.Count > 4) { %> class="overcome" <% } else { %> class="nonovercome" <% } %> >
                    <table width="100%">
                        <%
               for (int i = 0; i < Model.ListUserNotInDepartment.Count; i++)
                        {
                            if (i % 2 == 0)
                            {
                                            %>
                                                <tr>
                                            <%
                            }
                                            %>                                        
                                            <td style="width:5%; text-align:right">
                                                <input type="checkbox" id="chkUser<%= Model.ListUserNotInDepartment[i].ID %>" name="chkUser" value="0"
                                                    <% if (Model.ID > 0) { if( Model.CheckInThanhPhanThamDu(Model.ListUserNotInDepartment[i].ID) ){%> checked="checked" <%}}%>
                                                     />&nbsp;
                                            </td>
                                            <td style="width:28%">
                                                <div id="UserText<%= Model.ListUserNotInDepartment[i].ID %>">
                                                    <%= Model.ListUserNotInDepartment[i].LastName + " " + Model.ListUserNotInDepartment[i].FirstName%> 
                                                </div>
                                            </td>
                                            <%
                            if (i % 2 == 2)
                            {
                                            %>
                                                </tr>
                                            <%
                            }
                                            %> 
                        <%
                        }
                        %>
                    </table>
               </div>
            <% 
            foreach (TB_Department item in Model.ListPhongBan)
            {
                List<TB_User> listUser = Model.GetUserByDepartment(Model.ListUser, item.ID);
                if (listUser.Count > 0)
                {
                %>
            <div style="margin:0px 0px 10px 10px; cursor: pointer;" class="bo">
                <div id="Show_HideBut<%= item.ID %>" class="UnExpanted" onclick="Show_Hide(<%= item.ID %>)" ></div>
                <input type="checkbox" id="chkdep<%= item.ID %>" name="chkdep" onchange="javascript:DoCheckAll(<%= item.ID %>)" value="<%= item.ID %>"
                    <% if (Model.CheckCheckboxIsFull(item.ID)) { %> checked="checked" <% } %> />
                <b onclick="Show_Hide(<%= item.ID %>)" style="display:inline;"><%= item.DepartmentName%> &nbsp;</b>
            </div>            
            <div id="open_close<%= item.ID %>" <% if (listUser.Count > 4) { %> class="overcome" <% } else { %> class="nonovercome" <% } %> >
                <table width="100%"  class="data display datatable">
                    <%
                    for (int i = 0; i < listUser.Count; i++)
                    {
                        if (i % 2 == 0)
                        {
                                        %>
                                            <tr>
                                        <%
                        }
                                        %>                                        
                                        <td style="width:5%; text-align:right">
                                            <input type="checkbox" id="chkUser<%= listUser[i].ID %>" name="chkUser" value="<%= item.ID %>"
                                                <% if (Model.ID > 0) { if( Model.CheckInThanhPhanThamDu(listUser[i].ID) ){%> checked="checked" <%}}%>
                                                onclick="javascript:DoCheckBoxCheckAll(<%= item.ID %>)" />&nbsp;
                                        </td>
                                        <td style="width:28%">                                            
                                                <div id="UserText<%= listUser[i].ID %>">
                                                    <%= listUser[i].LastName + " " + listUser[i].FirstName%> 
                                                </div>
                                        </td>
                                        <%
                        if (i % 2 == 2)
                        {
                                        %>
                                            </tr>
                                        <%
                        }
                                        %> 
                    <%
                    }
                    %>
                    <tr><td><input type="hidden" id="input<%= item.ID %>" value="<%= listUser.Count %>" /></td></tr>
                </table>
            </div>
                <%
                }
            }
        %>
        </div>
        <div class="pagebreak"> &nbsp;</div>
        <div style="text-align: right; width: 95%;">
            <input type="button" value="Chọn" onclick="javascript:DoChonThanhPhan();" />
            <input type="button" value="Chọn lại" onclick="javascript:ResertFormThanhPhan();" />
            <input type="button" value="Đóng" onclick="javascript:$('#ThanhPhan').dialog('close');" />
        </div>
        </form>
    </div>
</asp:Content>
